package com.cysnake.quitsmoke.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class FormatTools {
	private static SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd");
	public static Date stringToDate(String str) throws ParseException{
		Date date=sim.parse(str);
		return date;
	}
	
	public static String dateToString(Date date){
		return sim.format(date);
	}
	
	public static String calenderToString(Calendar calender){
		if(calender!=null){
			return calender.get(Calendar.YEAR)+"-"+(calender.get(Calendar.MONTH)+1)+"-"+calender.get(Calendar.DAY_OF_MONTH);
		}
		return null;
	}
}
